package org.example.springboot.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import com.fasterxml.jackson.annotation.JsonFormat;

import java.sql.Timestamp;

@Data
@Schema(description = "联系商家消息实体")
@TableName("message")
public class Message {
    @TableId(type = IdType.AUTO)
    @Schema(description = "消息ID")
    private Long id;

    @Schema(description = "发送者用户ID")
    private Long senderId;

    @Schema(description = "接收者用户ID（商户）")
    private Long receiverId;

    @Schema(description = "商品ID")
    private Long productId;

    @Schema(description = "消息内容")
    private String content;

    @Schema(description = "消息状态：0-未读，1-已读")
    private Integer status = 0;

    @Schema(description = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Timestamp createdAt;

    @Schema(description = "更新时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Timestamp updatedAt;

    @Schema(description = "消息类型：0-对话消息，1-物流消息，2-支付消息，3-评价消息")
    private Integer messageType;

    // 新增对话相关字段
    @Schema(description = "父消息ID（用于对话回复）")
    private Long parentId;

    @Schema(description = "对话ID（同一对话的消息使用相同ID）")
    private Long conversationId;

    @TableField(exist = false)
    @Schema(description = "发送者信息")
    private User sender;

    @TableField(exist = false)
    @Schema(description = "回复消息列表")
    private java.util.List<Message> replies;
}